#d导入selenium
from selenium import webdriver
import pandas as pd
driver=webdriver.Firefox()
driver.get("https://github.com/collections/machine-learning")
#提取所有项目
projects = driver.find_elements_by_xpath("//h1[@class='h3 lh-condensed']")
# 提取每个项目的信息
project_list1 = {}
for proj in projects:
    proj_name = proj.text # 项目名称
    #项目的URL
    proj_url = proj.find_elements_by_xpath("a")[0].get_attribute('href')
    project_list1[proj_name] = proj_url
driver.quit()

# 导出数据
project_df =pd.DataFrame.from_dict(project_list1, orient = 'index')
project_df['project_name'] = project_df.index
project_df.columns = ['project_url', 'project_name']
project_df = project_df.reset_index(drop=True)
project_df['project_name'] = project_df.index
project_df.columns = ['project_url', 'project_name']
project_df = project_df.reset_index(drop=True)
project_df.to_csv('project_list1.csv')